//
//  EmoticonAttachment.swift
//  EmoticonKeyBoard
//
//  Created by Arvin on 15/11/22.
//  Copyright © 2015年 Arvin. All rights reserved.
//

import UIKit

class EmoticonAttachment: NSTextAttachment {
    
    var chs: String?
    
    // 将图片转换为属性文本
    func getAttubitedString(font: UIFont?, emoticon: Emoticon, range: NSRange) -> NSMutableAttributedString {
  
        chs = emoticon.chs
        let height = font?.lineHeight
        bounds = CGRectMake(0, -4, height!, height!)
        image = emoticon.imagePng
        let attachAttrib = NSAttributedString(attachment: self)
        let attachAttribM = NSMutableAttributedString(attributedString: attachAttrib)
        attachAttribM.addAttribute(NSFontAttributeName, value: font!, range: NSMakeRange(0, 1))
        return attachAttribM
    }
    
    
}
